<!DOCTYPE html>
<html lang="en" xmlns:c="http://www.w3.org/1999/XSL/Transform">
<head>
    <meta charset="UTF-8">
    <title>场馆</title>
    <link rel="stylesheet" type="text/css" href="../bootstrap核心/bootstrap.min.css">
    <script src="https://code.jquery.com/jquery-1.9.1.min.js"></script>
    <!-- 生成弹框、提示框、下拉菜单的 -->
    <script type="text/javascript" src="../bootstrap核心/popper.min.js"></script>
    <!-- bootstrap的js，用于响应事件 -->
    <script type="text/javascript" src="../bootstrap核心/bootstrap.min.js"></script>
    <script src="../layui/layui.js"></script>
    <link rel="stylesheet" href="../layui/css/layui.css" media="all"/>
    <style>
        a{
            text-decoration: none
        }
        body{
            background-color: rgba(0,0,0,0.05);
        }
        #allTrainersInThisGym{
            background-color: rgba(0,0,0,0.05);
        }
        #mainContent{
            width: 100%;
            height: auto;
            text-align: center;
            background-color: rgba(0,0,0,0.05);
        }
        #mainContent button{
            float: left;
            margin-left: 20%;
        }
        .showTrainer{
            width: 85%;
            font-size: larger;
            float: left;
        }
        .trainerPic{
            width: 300px;
            height: 150px;
            border: 1px solid gray;
            margin: auto;
        }
        .oneTrainer{
            width: 350px;
            height: 700px;
            text-align: center;
            margin-left: 30px;
            float: left;
        }
        .gymInfor{
            width: 100%;
            height: 1200px;
            background-color: rgba(0,0,0,0.05);
            line-height: 50px;
        }
        .gymInfor h2{
            margin-right: 30%;
        }
        .gymInfor p{
            margin-right: 20%;
        }
        .gymPics img{
            width: 30%;
            height: auto;
            float: left;
            margin-left: 10%;
            margin-top: 30px;
        }
        .layui-col-md12{
            float: left;
            width: 1400px;
            margin-top: 20px;
            margin-left: 100px;
            text-align: left;
            font-size: larger;
        }
        .layui-card-header{
            color: #6c757d;
        }
        .layui-card-body{
            color: #721c24;
        }
        body .layui-open-setbgc .layui-layer-content{background: #f2f2f2;}
        .input-group{
            margin-top: 30px;
        }
        .input-group-btn{
            margin-top: 10px;
        }
    </style>
</head>
<body>
    <script>
        $(function () {
            //静态包含头部文件
            $.ajax({
                type:"get",
                url:"platformAndGymHead.html",
                async:true,
                success:function(data){
                    $("#header").html(data);
                }
            });

            //html跳页面传参
            var arg;

            $.ajax({
                type:"get",
                url:"/gymVerify/getGymValue",
                success:function(data) {
                    arg=data.tGym.gId;


                    $.ajax({
                        url:'/platForm/findGymByGid',
                        type:'post',
                        data:{
                            gId:arg,
                        },
                        dataType:'json',
                        success:function (data) {
                            var content='<a href="#" style="height: 100px;font-size: 30px;line-height: 100px;color: #5FB878">'+data.gym.gName+'<input type="hidden" id="gid" value="'+data.gym.gId+'"></a>';
                            $("#gymName").html(content);
                            if (data.gym.gState==1){
                                content="签约状态：&nbsp&nbsp&nbsp解约";
                                $("#gState").html(content);
                                content="<a href='' onclick='SignWithPlatform()'>申请签约</a>";
                                $("#gStateOperation").html(content);
                            }else{
                                content="签约状态：&nbsp&nbsp&nbsp已签约";
                                $("#gState").html(content);
                                // content="<a href='' onclick='rescissionWithPlatform()'>申请解约</a>";
                                // $("#gStateOperation").html(content);
                            }
                        }
                    })
                    $.ajax({
                        url:'/gym/findTrainerAgreementsByGymid',
                        type:'post',
                        data:{
                            gid:arg,
                            page:1,
                        },
                        dataType:'json',
                        success:function (data) {
                            var content;
                            var num=data.rows.length;
                            var total=data.total;
                            if (total=1&&num>0){
                                content='<span class="layui-badge-dot" style="float: left"></span>';
                                $("#redPot").html(content);
                                content='处理教练申请（'+num+'条）'
                                $("#handler").html(content);
                            }else if (total>1){
                                content='<span class="layui-badge-dot" style="float: left"></span>';
                                $("#redPot").html(content);
                                content='处理教练申请（10+条）'
                                $("#handler").html(content);
                            }
                        }
                    })





                }
            });


        })
        layui.use('carousel', function(){
            var carousel = layui.carousel;
            //建造实例
            carousel.render({
                elem: '#test1'
                ,width: '100%' //设置容器宽度
                ,height:'1000px'
                ,arrow: 'always' //始终显示箭头
                //,anim: 'updown' //切换动画方式
            });
        });
    </script>
    <input type="hidden" id="GymId" value="">
    <header class="header" id="header"></header>
    <!--<div id="showOneGym" class="mainContent">
    </div>-->

    <ul class="layui-nav layui-nav-tree" lay-filter="test" style="float: left;height:1200px;width: 14.85% ">
        <!-- 侧边导航: <ul class="layui-nav layui-nav-tree layui-nav-side"> -->
        <li class="layui-nav-item" id="gymName" style="height: 100px"><a href="" style="height: 100px"></a></li>
        <li class="layui-nav-item layui-nav-itemed">
            <a href="javascript:;">教练</a>
            <dl class="layui-nav-child">
                <dd><a href="javascript:;" onclick="findTrainersByGid(1)">查看已签约教练</a></dd>
                <dd><a href="javascript:;" onclick="contractAuditWithTrainer(1)" id="handler">处理教练申请</a><div id="redPot"></div></dd>
                <dd><a href="javascript:;" onclick="rescissionWithTrainer(1)">与教练解约</a></dd>
            </dl>
        </li>
        <li class="layui-nav-item">
            <a href="javascript:;">我的场馆</a>
            <dl class="layui-nav-child">
                <dd><a href="javascript:;" onclick="SearchGymInformation()">场馆信息</a></dd>
                <dd><a href="javascript:;" onclick="modifyGymInformation()">修改场馆信息</a></dd>
                <dd><a href="javascript:;" onclick="findOrdersByGid(1)">查看订单</a></dd>
                <dd><a href="javascript:;" onclick="checkBalance()">余额</a></dd>
                <dd><a href="">经营分析</a></dd>
            </dl>
        </li>
        <li class="layui-nav-item">
            <a href="javascript:;">平台</a>
            <dl class="layui-nav-child">
                <dd><a href="" id="gState">签约状态：</a></dd>
<!--                <dd id="gStateOperation"><a href="" ></a></dd>-->
            </dl>
        </li>
    </ul>

    <div id="mainContent">

    </div>
    <table class="layui-hide" id="test" style="float: left;margin-left: 15%;margin-top: 200px"></table>
<script>

    function modifyGymInformation() {
        $.ajax({
            url: '/platForm/findGymByGid',
            type: 'post',
            data: {
                gId: $("#gid").val()
            },
            success: function (data) {
                var content='<div class="add_div">' +
                    '    <div style="margin-top: 20px;margin-left: 40%;width: 500px">' +
                    '        <h1 class="text-muted" style="text-align: center">修改场馆信息</h1>' +
                    '        <form class="bs-example bs-example-form" role="form">' +
                    '            <div class="input-group">' +
                    '                <span class="input-group-btn">馆名：</span>' +
                    '                <input type="text" class="form-control" value="'+data.gym.gName+'" id="name">' +
                    '            </div>' +
                    '            <div class="input-group">' +
                    '                <span class="input-group-btn">介绍：</span>' +
                    '                <input type="text" class="form-control" value="'+data.gym.gIntroduction+'" id="introduction">' +
                    '            </div>' +
                    '            <div class="input-group">' +
                    '                <span class="input-group-btn">地址：</span>' +
                    '                <input type="text" class="form-control" value="'+data.gym.gAddress+'" id="address">' +
                    '               <div class="layui-form-item" style="margin-left: 100px;">\n' +
                    '                   <fieldset class="layui-elem-field layui-field-title" style="margin-top: 10px; width: 800px;margin-left: -300px">\n' +
                    '                       <legend>请选择地址信息</legend>\n' +
                    '                   </fieldset>\n' +
                    '               </div>\n' +
                    '               <iframe id="mapPage" width="100%" height="400px" frameborder=0 style="margin-top: -20px"\n' +
                    '                    src="http://apis.map.qq.com/tools/locpicker?search=1&type=1&key=OB4BZ-D4W3U-B7VVO-4PJWW-6TKDJ-WPB77&referer=myapp">\n' +
                    '               </iframe>'+
                    '            </div>' +
                    '            <div class="input-group">' +
                    '                <span class="input-group-btn">图片：</span>' +
                    '                <input type="file" class="form-control" multiple="multiple" id="choose-file">' +
                    '            </div>' +
                    '            <p>' +
                    '            <ul class="file-list " id="oldImg">';
                        for(var i=0;i<data.imgs.length;i++){
                            var po=data.imgs[i];
                            content+='<li class="file-item"><img src="../image/'+po+'" alt="" height="70" id="img'+i+'"><span class="file-del"><button type="button" class="layui-btn layui-btn-normal">删除</button></span></li>'
                        }
                        content+='</ul>' +
                    '            </p>' +
                    '            <button type="button" style="cursor: pointer;margin-left: 200px;margin-top: 30px" id="upload" class="layui-btn">上传</button>' +
                    '            <br>' +
                    '        </form>' +
                    '    </div>' +
                    '</div>';
                $("#mainContent").html(content);
                ////////////////////////////////////////////////图片上传//////////////////////////////////////////////
                //声明变量
                var $button = $('#upload'),
                    //选择文件按钮
                    $file = $("#choose-file"),
                    //回显的列表
                    $list = $('.file-list'),
                    //选择要上传的所有文件
                    fileList = [];
                //当前选择上传的文件
                var curFile;
                console.log(fileList);
                // 选择按钮change事件，实例化fileReader,调它的readAsDataURL并把原生File对象传给它，
                // 监听它的onload事件，load完读取的结果就在它的result属性里了。它是一个base64格式的，可直接赋值给一个img的src.
                $file.on('change', function (e) {
                    curFile = this.files;
                    //curFile = $file.get(0).files;
                    console.log(curFile);
                    //将FileList对象变成数组
                    fileList = fileList.concat(Array.from(curFile));
                    console.log(fileList);
                    for (var i = 0, len = curFile.length; i < len; i++) {
                        reviewFile(curFile[i])
                    }
                    $('.file-list').fadeIn(2500);
                })


                function reviewFile(file) {
                    //实例化fileReader,
                    var fd = new FileReader();
                    //获取当前选择文件的类型
                    var fileType = file.type;
                    //调它的readAsDataURL并把原生File对象传给它，
                    fd.readAsDataURL(file);//base64
                    //监听它的onload事件，load完读取的结果就在它的result属性里了
                    fd.onload = function () {
                        if (/^image\/[jpeg|png|jpg|gif]/.test(fileType)) {
                            $list.append('<li class="file-item"><img src="' + this.result + '" alt="" height="70"><span class="file-del"><button type="button" class="layui-btn layui-btn-normal">删除</button></span></li>').children(':last').hide().fadeIn(2500);
                        } else {
                            $list.append('<li class="file-item"><span class="file-name">' + file.name + '</span><span class="file-del">删除</span></li>')
                        }

                    }
                }

                //点击删除按钮事件：
                $(".file-list").on('click', '.file-del', function () {
                    let $parent = $(this).parent();
                    console.log($parent);
                    let index = $parent.index();
                    fileList.splice(index, 1);
                    $parent.fadeOut(850, function () {
                        $parent.remove()
                    });
                });
                var detail;
                var latlng;
                var address;
                window.addEventListener('message', function(event) {
                    // 接收位置信息，用户选择确认位置点后选点组件会触发该事件，回传用户的位置信息
                    var loc = event.data;
                    if (loc && loc.module == 'locationPicker') {//防止其他应用也会向该页面post信息，需判断module是否为'locationPicker'
                        console.log('location', loc);
                        detail = loc.poiaddress;
                        console.log("detail",detail);
                        address=detail;
                        //获取经纬度并且赋值
                        var lat = loc.latlng.lat;
                        var lng = loc.latlng.lng;
                        //经纬度拼接
                        latlng = lat+","+lng;
                        console.log("latlng","latlng是："+latlng);
                    }
                }, false);
                //点击上传按钮事件：
                $button.on('click', function () {
                    var imgs='';
                    for (var i=0;i<data.imgs.length;i++){
                        imgs+=data.imgs[i]+';';
                    }
                    var name = $('#name').val();
                    var introduction = $('#introduction').val();
                    layui.use('layer', function(){ //独立版的layer无需执行这一句
                        var $ = layui.jquery, layer = layui.layer;
                        if (name == '') {
                            layer.msg('场馆名不能为空', {icon: 5,anim:6});
                            return;
                        }
                        if(fileList.length > 10){
                            layer.msg('最多允许上传10张图片', {icon: 5,anim:6});
                            return;
                        } else {
                            var formData = new FormData();
                            fileList.forEach(function (file) {
                                formData.append('file', file, file.name);
                            })
                            formData.append('gImage',imgs);
                            formData.append('gId', data.gym.gId);
                            formData.append('gName', name);
                            formData.append('gIntroduction', introduction);
                            formData.append('gLatlng',latlng);
                            formData.append('gAddress',address);
                            $.ajax({
                                url: '/gym/InformationModify',
                                type: 'post',
                                data: formData,
                                processData: false,
                                contentType: false,
                                success:function (data) {
                                    layer.alert(data);
                                },
                            });
                            // layui.use('layer', function(){ //独立版的layer无需执行这一句
                            //     var $ = layui.jquery, layer = layui.layer;
                            //
                            // })
                        }
                    })

                })
            }
        })

    }

    function findOrdersByGid(currentPage) {
        $.ajax({
            url:'/gym/findOrdersByGymid',
            type:'post',
            data:{
                gid:$("#gid").val(),
                page:currentPage
            },
            dataType:'json',
            success:function (data) {
                var content='<table class="table table-bordered table-hover" style="width: 1300px;float: left;">'
                    +'<thead>'
                    +'<tr style="background-color: #545b62">'
                    +'<th>学员姓名</th>'
                    +'<th>教练姓名</th>'
                    +'<th>订单金额</th>'
                    +'<th>订单号</th>'
                    +'<th>支付宝交易号</th>'
                    +'<th>订单状态</th>'
                    +'<th>教练分成</th>'
                    +'<th>场馆分成</th>'
                    +'<th>平台分成</th>'
                    +'<th>订单创建时间</th>'
                    +'<th>订单更新时间</th>'
                    +'<th>查看评价</th>'
                    +'</tr>'
                    +'</thead>'
                    +'<tbody>'
                for (var i=0;i<data.rows.length;i++){
                    var po=data.rows[i];
                    var oStates='';
                    if (po.oState=='已完成'){
                        oStates='<td><div style="width: 50px;height: 20px;background-color: #5FB878; margin-left: 40px;color: white">'+po.oState+'</div></td>'
                    }else {
                        oStates='<td><div style="width: 50px;height: 20px;background-color: #b21f2d; margin-left: 40px;color: white">'+po.oState+'</div></td>'
                    }
                    content+='<tr style="color: black">'
                        +'<td>'+po.sName+'</td>'
                        +'<td>'+po.tName+'</td>'
                        +'<td>'+po.oBanlance+'</td>'
                        +'<td>'+po.oNum+'</td>'
                        +'<td>'+po.oAlinum+'</td>'
                        +oStates
                        +'<td>'+po.oTrainerbanlance+'</td>'
                        +'<td>'+po.oGymbanlance+'</td>'
                        +'<td>'+po.oPlatformbanlance+'</td>'
                        +'<td>'+po.oCreatetime+'</td>'
                        +'<td>'+po.oUpdatetime+'</td>'
                        +'<td><button type="button" class="btn btn-info" onclick="viewEvaluation('+po.oId+')">查看</button></td>'
                        +'</tr>'
                }
                content+='</tbody>'
                    +'</table>';
                content+='<div class="container" style="float: left; width: 800px;height: 100px;">' +
                    '<ul class="pagination">' +
                    '<li class="page-item"><a class="page-link" onclick="prePagefindOrders('+currentPage+')">前一页</a></li>';
                for(var i=0;i<data.total;i++){
                    var page=i+1;
                    content+='<li class="page-item"><a class="page-link" onclick="findOrdersByGid('+page+')">'+page+'</a></li>'
                };
                content+='<li class="page-item"><a class="page-link" onclick="nextPagefindOrders('+currentPage+','+data.total+')">下一页</a></li>' +
                    '</ul>' +
                    '</div>';
                $("#mainContent").html(content);
            },
            error:function () {
                var content='<div style="width: 100%;height: 100px;line-height: 100px;text-align: center;font-size: 30px">场馆还没有订单</div>';
                $("#mainContent").html(content);
            }
        })
    }
    function nextPagefindOrders(currentPage,totalPage){
        if(currentPage<totalPage){
            findGyms(currentPage+1)
        }
    }
    function prePagefindOrders(currentPage){
        if(currentPage>1){
            findGyms(currentPage-1)
        }
    }
    function viewEvaluation(oid) {
        $.ajax({
            url:'/platForm/findEvalutionByOid',
            type:'post',
            data:{
                oid:oid,
            },
            dataType:'json',
            success:function (data) {
                var eStar='';
                for (var i=0;i<data.eStar;i++){
                    eStar+='<i class="layui-icon" style="font-size: 50px; color: #fd7e14;float: left;margin-left: 15px">&#xe67a;</i>'
                }
                for (var i=0;i<5-data.eStar;i++){
                    eStar+='<i class="layui-icon" style="font-size: 50px; color: #fd7e14;float: left;margin-left: 15px">&#xe67b;</i>'
                }
                var evalution=' <div class="layui-col-md6" style="margin-top: 50px;width: 100%;height: 350px;">' +
                    '      <div class="layui-card">' +
                    '        <div class="layui-card-header" style="font-size: larger">评价详情</div>' +
                    '        <div class="layui-card-body">' +
                    data.eMessage+
                    '        </div>' +
                    '      </div>' +
                    '    </div>'
                var content='<div style="width: 500px; height: 150px;">' +
                    '<div style="width: 400px; height: 100px; line-height: 100px;margin-left: 50px;margin-top: 20px;">' +
                    eStar+
                    '</div>' +
                    evalution+
                    '</div>';
                layui.use('layer', function() { //独立版的layer无需执行这一句
                    var $ = layui.jquery, layer = layui.layer;
                    layer.ready(function(){
                        layer.open({
                            type: 1,
                            title:'<h3 style="text-align: center;color: #009E94"><i class="layui-icon" style="font-size: 30px; color: #009E94;">&#xe642;</i>学员评价</h3>',
                            area:['500px','600px'],
                            skin:'layui-open-setbgc',
                            closeBtn: 0, //不显示关闭按钮
                            shadeClose: true, //开启遮罩关闭
                            content: content
                        });
                    })
                })

            },
            error:function () {
                layui.use('layer', function() { //独立版的layer无需执行这一句
                    var $ = layui.jquery, layer = layui.layer;
                    layer.alert('<div style="text-align: center"><i class="layui-icon" style="font-size: 30px; color: #1E9FFF;">&#xe642</i>此订单还没有评价</div>');
                })
            }
        })
    }


    function SignWithPlatform() {
        alert("申请与平台签约")
    }

    function rescissionWithPlatform() {
        alert("申请与平台解约")
    }

    function checkBalance() {
        $.ajax({
            url:'/gym/findBalanceByGid',
            type:'post',
            data:{
                gid:$("#gid").val()
            },
            dataType:'json',
            success:function (data) {
                var content='<div class="layui-row" style="float: left; width: 70%;height: 800px">'
                    +'<div class="layui-col-xs12" style="text-align: center; margin-top: 100px;" >'
                    +'<i class="layui-icon layui-icon-rmb" style="font-size: 70px; color: orange;"></i>'
                    +'</div>'
                    +'<div class="layui-col-xs12" style="text-align: center; margin-top: 30px; font-size: 16px">账户余额</div>'
                    +'<div class="layui-col-xs12" style="text-align: center; margin-top: 40px; font-size: 35px;font-weight: 700;">'
                    +'￥&nbsp;<label>'+data+'</label>'
                    +'</div>'
                    +'<div class="layui-col-xs12" style="text-align: center; margin-top: 40px; font-size: 16px">'
                    +'<button type="button" class="layui-btn layui-btn-sm" style="margin-left: 49%">充值</button>'
                    +'</div>'
                    +'</div>';
                $("#mainContent").html(content);
            }
        })
    }

    function rescissionWithTrainer(currentPage) {
        $.ajax({
            url:'/gym/findTrainersByGymid',
            type:'post',
            data:{
                gid:$("#gid").val(),
                page:currentPage,
            },
            dataType:'json',
            success:function (data) {
                var content='<div class="showTrainer">' +
                    '            <hr class="layui-bg-gray">' +
                    '            <div class="layui-col-md6" style="text-align: center; width: 100%">' +
                    '                <div class="layui-card">' +
                    '                    <div class="layui-card-header" style="font-size: 30px;height: 100px;line-height: 100px">已签约教练</div>' +
                    '                    <div class="layui-card-body" id="allTrainersInThisGym" style="height: 850px">';
                for (var i=0;i<data.rows.length;i++){
                    var po=data.rows[i];
                    content+='<div class="oneTrainer">'
                        +'<div class="trainerPic"><img src="../image/'+po.tImage+'" style="width: 100%;height: 150px"></div>'
                        +'<div class="layui-col-md12" style="margin-left: 10px; width: 330px;">' +
                        '  <div class="layui-card">' +
                        '<div class="layui-card-header">教练名</div>'+
                        '    <div class="layui-card-body">'+po.tName+'</div>' +
                        '  </div>' +
                        '</div>'
                        +'<button type="button" class="btn btn-danger" onclick="rescission('+po.tId+','+currentPage+')" style="margin-left: 150px">解约</button>'
                        +'</div>';
                }
                content+='</div>' +
                    '                </div>' +
                    '            </div>' +
                    '        </div>'
                content+='<div class="container" style="float: left; width: 800px;height: 100px;">' +
                    '<ul class="pagination">' +
                    '<li class="page-item"><a class="page-link" onclick="prePageRescission('+currentPage+')">前一页</a></li>';
                for(var i=0;i<data.total;i++){
                    var page=i+1;
                    content+='<li class="page-item"><a class="page-link" onclick="rescissionWithTrainer('+page+')">'+page+'</a></li>'
                };
                content+='<li class="page-item"><a class="page-link" onclick="nextPageRescission('+currentPage+','+data.total+')">下一页</a></li>' +
                    '</ul>' +
                    '</div>';
                $("#mainContent").html(content);
            }
        })
    }
    function nextPageRescission(currentPage,totalPage){
        if(currentPage<totalPage){
            rescissionWithTrainer(currentPage+1)
        }
    }
    function prePageRescission(currentPage){
        if(currentPage>1){
            rescissionWithTrainer(currentPage-1)
        }
    }
    function rescission(tId,currentPage) {
        layui.use('layer', function() { //独立版的layer无需执行这一句
            var $ = layui.jquery, layer = layui.layer;
            layer.open({
                content: '确定与该教练解约吗？',
                btn: ["<i class=\"layui-icon\">&#xe605;</i>", "<i class=\"layui-icon\">&#x1006;</i>"],
                yes: function (index) {
                    $.ajax({
                        url:'/gym/rescissionWithTrainer',
                        type:'post',
                        data:{
                            gid:$("#gid").val(),
                            tid:tId,
                        },
                        success:function () {
                            layer.alert("<div style='text-align: center'><i class=\"layui-icon\" style='font-size: 30px; color: #009E94'>&#xe60c;</i>解约成功！</div>");
                            rescissionWithTrainer(currentPage);
                        }
                    })
                    layer.close(index);
                },
                btn2: function (index) {
                }
            })
        })
    }


    function findTrainersByGid(currentPage){
        $.ajax({
            url:'/gym/findTrainersByGymid',
            type:'post',
            data:{
                gid:$("#gid").val(),
                page:currentPage,
            },
            dataType:'json',
            success:function (data) {
                var content='<div class="showTrainer">' +
                    '            <hr class="layui-bg-gray">' +
                    '            <div class="layui-col-md6" style="text-align: center; width: 100%">' +
                    '                <div class="layui-card">' +
                    '                    <div class="layui-card-header" style="font-size: 30px;height: 100px;line-height: 100px">已签约教练</div>' +
                    '                    <div class="layui-card-body" id="allTrainersInThisGym" >';
                for (var i=0;i<data.rows.length;i++){
                    var po=data.rows[i];
                    var count=0;
                    var star='';
                    for (var j=0;j<=po.star-1;j++){
                        star+='<i class="layui-icon" style="font-size: 20px; color: #fd7e14;float: left;margin-left: 5px">&#xe67a;</i>'
                        count++;
                    }
                    if((po.star-count)>0&&(po.star-count<0.5)){
                        star+='<i class="layui-icon" style="font-size: 20px; color: #fd7e14;float: left;margin-left: 5px">&#xe6c9;</i>'
                    }
                    else if(po.star-count>0.5){
                        star+='<i class="layui-icon" style="font-size: 20px; color: #fd7e14;float: left;margin-left: 5px">&#xe67a;</i>'
                    }
                    if (po.star==null){
                        star='该教练还未完成过订单';
                    }
                    content+='<div class="oneTrainer" style="margin-top: 50px">'
                        +'<div class="trainerPic"><img src="../image/'+po.tImage+'" style="width: 100%;height: 150px"></div>'
                        +'<div class="layui-col-md12" style="margin-left: 10px; width: 330px">' +
                        '  <div class="layui-card">' +
                        '<div class="layui-card-header">教练名</div>'+
                        '    <div class="layui-card-body">'+po.tName+'</div>' +
                        '  </div>' +
                        '</div>'
                        +'<div class="layui-col-md12" style="margin-left: 10px; width: 330px;">' +
                        '  <div class="layui-card">' +
                        '<div class="layui-card-header">介绍</div>'+
                        '    <div class="layui-card-body" style="font-size:8px;height: 200px">'+po.tIntroduction+'</div>' +
                        '  </div>' +
                        '</div>'
                        +'<div class="layui-col-md12" style="margin-left: 10px; width: 330px">' +
                        '  <div class="layui-card">' +
                        '<div class="layui-card-header">地址</div>'+
                        '    <div class="layui-card-body" style="font-size: 8px">'+po.tAddress+'</div>' +
                        '  </div>' +
                        '</div>'
                        +'<div class="layui-col-md12" style="margin-left: 10px; width: 330px">' +
                        '  <div class="layui-card">' +
                        '<div class="layui-card-header">综合评价</div>'+
                        '    <div class="layui-card-body" style="font-size:8px;height: 50px">'+star+'</div>' +
                        '  </div>' +
                        '</div>'
                        +'</div>';
                }
                content+='</div>' +
                    '                </div>' +
                    '            </div>' +
                    '        </div>'
                content+='<div class="container" style="float: left; width: 800px;height: 100px; margin-top: 70px;margin-left: 30px">' +
                    '<ul class="pagination">' +
                    '<li class="page-item"><a class="page-link" onclick="prePagefindTrainers('+currentPage+')">前一页</a></li>';
                for(var i=0;i<data.total;i++){
                    var page=i+1;
                    content+='<li class="page-item"><a class="page-link" onclick="findTrainersByGid('+page+')">'+page+'</a></li>'
                };
                content+='<li class="page-item"><a class="page-link" onclick="nextPagefindTrainers('+currentPage+','+data.total+')">下一页</a></li>' +
                    '</ul>' +
                    '</div>';
                $("#mainContent").html(content);
            }
        })
    }
    function nextPagefindTrainers(currentPage,totalPage){
        if(currentPage<totalPage){
            findTrainersByGid(currentPage+1)
        }
    }
    function prePagefindTrainers(currentPage){
        if(currentPage>1){
            findTrainersByGid(currentPage-1)
        }
    }


    function contractAuditWithTrainer(currentPage) {
        $.ajax({
            url:'/gym/findTrainerAgreementsByGymid',
            type:'get',
            data:{
                gid:$("#gid").val(),
                page:currentPage,
            },
            dataType:'json',
            success:function (data) {
                var content='<table class="table table-bordered table-hover" style="width: 1300px;float: left;">'
                +'<thead>'
                +'<tr style="background-color: #545b62">'
                    +'<th>签约号</th>'
                    +'<th>教练姓名</th>'
                    +'<th>场馆抽成比例</th>'
                    +'<th>申请时间</th>'
                    +'<th></th>'
                    +'</tr>'
                    +'</thead>'
                    +'<tbody>'
                    for (var i=0;i<data.rows.length;i++){
                        var po=data.rows[i];
                        content+='<tr style="color: black">'
                            +'<td>'+po.taId+'</td>'
                            +'<td>'+po.tName+'</td>'
                            +'<td>'+po.taGymratio+'</td>'
                            +'<td>'+po.taUpdatetime+'</td>'
                            +'<td><button type="button" class="btn btn-info" onclick="passContract('+po.taId+','+currentPage+')">通过</button><button type="button" class="btn btn-danger" onclick="refuseContract('+po.taId+','+currentPage+')">拒绝</button><br></td>'
                            +'</tr>'
                    }
                    content+='</tbody>'
                    +'</table>';
                content+='<div class="container" style="float: left; width: 800px;height: 100px;">' +
                    '<ul class="pagination">' +
                    '<li class="page-item"><a class="page-link" onclick="prePageContractAudit('+currentPage+')">前一页</a></li>';
                for(var i=0;i<data.total;i++){
                    var page=i+1;
                    content+='<li class="page-item"><a class="page-link" onclick="contractAuditWithTrainer('+page+')">'+page+'</a></li>'
                };
                content+='<li class="page-item"><a class="page-link" onclick="nextPageContractAudit('+currentPage+','+data.total+')">下一页</a></li>' +
                    '</ul>' +
                    '</div>';
                $("#mainContent").html(content);
            }
        })
    }
    function nextPageContractAudit(currentPage,totalPage){
        if(currentPage<totalPage){
            contractAuditWithTrainer(currentPage+1)
        }
    }
    function prePageContractAudit(currentPage){
        if(currentPage>1){
            contractAuditWithTrainer(currentPage-1)
        }
    }
    function passContract(taId,currentPage) {
        layui.use('layer', function() { //独立版的layer无需执行这一句
            var $ = layui.jquery, layer = layui.layer;
            layer.open({
                content: '确定与该教练签约吗？',
                btn: ["<i class=\"layui-icon\">&#xe605;</i>", "<i class=\"layui-icon\">&#x1006;</i>"],
                yes: function (index) {
                    $.ajax({
                        url:'/gym/contractAudit',
                        type:'get',
                        data:{
                            taid:taId,
                            flag:1,
                        },
                        success:function (data) {
                            layer.alert("<div style='text-align: center'><i class=\"layui-icon\" style='font-size: 30px; color: #009E94'>&#xe60c;</i>签约成功！</div>")
                            contractAuditWithTrainer(currentPage)
                        }
                    })
                    layer.close(index);
                },
                btn2: function (index) {
                }
            })
        })
    }
    function refuseContract(taId,currentPage){
        layui.use('layer', function() { //独立版的layer无需执行这一句
            var $ = layui.jquery, layer = layui.layer;
            layer.open({
                content: '确认拒绝该教练签约请求吗？',
                btn: ["<i class=\"layui-icon\">&#xe605;</i>", "<i class=\"layui-icon\">&#x1006;</i>"],
                yes: function (index) {
                    $.ajax({
                        url:'/gym/contractAudit',
                        type:'post',
                        data:{
                            taid:taId,
                            flag:0,
                        },
                        success:function (data) {
                            layer.alert("<div style='text-align: center'><i class=\"layui-icon\" style='font-size: 30px; color: #009E94'>&#xe60c;</i>拒绝了该教练的签约请求</div>")
                            contractAuditWithTrainer(currentPage)
                        }
                    })
                    layer.close(index);
                },
                btn2: function (index) {
                }
            })
        })
    }


    function SearchGymInformation() {
        $.ajax({
            url: '/platForm/findGymByGid',
            type: 'post',
            data: {
                gId: $("#gid").val()
            },
            success: function (data) {
                var content='<div class="gymInfor">'
                    +'<div class="layui-carousel" id="test1" style="margin-left: 15%">' +
                    '  <div carousel-item>';
                    for (var i=0;i<data.imgs.length;i++) {
                        var po = data.imgs[i];
                        content += '<div><img src="../image/' + po + '" style="width: 100%; height: 500px"/></div>'
                    }
                    content+='  </div></div>'
                            +'<div class="layui-col-md12" style="float: left;width: 1400px;margin-top: 20px;margin-left: 100px;text-align: left;font-size: larger;">' +
                        '  <div class="layui-card">' +
                            '<div class="layui-card-header">账号</div>'+
                        '    <div class="layui-card-body">'+data.gym.gAccount+'</div>' +
                        '  </div>' +
                        '</div>'
                        +'<div class="layui-col-md12" style="float: left;width: 1400px;margin-top: 20px;margin-left: 100px;text-align: left;font-size: larger;">' +
                        '  <div class="layui-card">' +
                        '<div class="layui-card-header">馆名</div>'+
                        '    <div class="layui-card-body">'+data.gym.gName+'</div>' +
                        '  </div>' +
                        '</div>'
                        +'<div class="layui-col-md12" style="float: left;width: 1400px;margin-top: 20px;margin-left: 100px;text-align: left;font-size: larger;">' +
                        '  <div class="layui-card">' +
                        '<div class="layui-card-header">介绍</div>'+
                        '    <div class="layui-card-body">'+data.gym.gIntroduction+'</div>' +
                        '  </div>' +
                        '</div>'
                        +'<div class="layui-col-md12" style="float: left;width: 1400px;margin-top: 20px;margin-left: 100px;text-align: left;font-size: larger;" >' +
                        '  <div class="layui-card">' +
                        '<div class="layui-card-header">地址</div>'+
                        '    <div class="layui-card-body">'+data.gym.gAddress+'</div>' +
                        '  </div>' +
                        '  <iframe id="mapPage" width="100%" height="400px" frameborder=0 style="margin-top: -20px"\n' +
                        '       src="http://apis.map.qq.com/tools/poimarker?type=0&marker=coord:'+data.gym.gLatlng+';addr:'+data.gym.gAddress+'&key=OB4BZ-D4W3U-B7VVO-4PJWW-6TKDJ-WPB77&referer=myapp">\n' +
                        '  </iframe>'+
                        '</div>';
                $("#mainContent").html(content);
                layui.use('carousel', function(){
                    var carousel = layui.carousel;
                    //建造实例
                    carousel.render({
                        elem: '#test1'
                        ,width: '100%' //设置容器宽度
                        ,arrow: 'hover' //始终显示箭头
                        //,anim: 'updown' //切换动画方式
                    });
                });
            }
        })
    }
</script>
</body>
</html>